package com.sikaryofficial.system.api.factory;

import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.RemoteQrCodeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 日志服务降级处理
 *
 * @author qinjinyuan
 */
@Component
public class RemoteQrCodeFallbackFactory implements FallbackFactory<RemoteQrCodeService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteQrCodeFallbackFactory.class);

    @Override
    public RemoteQrCodeService create(Throwable throwable) {
        log.error("二维码调用失败:{}", throwable.getMessage());
        return new RemoteQrCodeService() {
            /**
             * 二维码存在性判定
             *
             * @param param
             * @return
             */
            @Override
            public R<Boolean> existProductQrCode(String param) {
                return R.fail("二维码存在性判定失败:" + throwable.getMessage());
            }

            /**
             * 判定是否被扫码(是否获取100积分)
             *
             * @param param
             * @return
             */
            @Override
            public R<Boolean> verifyScanCode(String param) {
                return R.fail("判定是否被扫码(是否获取100积分)失败:" + throwable.getMessage());
            }

            /**
             * 设置扫码状态(是否获取100积分)
             *
             * @param param
             * @return
             */
            @Override
            public R<Boolean> updateProductQrData(String param) {
                return R.fail("设置扫码状态(是否获取100积分)失败:" + throwable.getMessage());
            }
        };
    }
}
